import java.util.Comparator;

public class Student implements Comparator<Student> {
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compare(Student student1,Student student2) {
        return student1.name.compareTo(student2.name);
    }   //String中正好有compareTo,避免了字符串直接相减报错

    }

